require('dotenv').config();
const express = require('express');
const cors = require('cors');

const app = express();

// 中间件
app.use(cors());
app.use(express.json());

// 简单的测试路由
app.get('/test', (req, res) => {
  res.json({ message: '服务器运行正常', timestamp: new Date().toISOString() });
});

// 健康检查
app.get('/health', (req, res) => {
  res.json({ 
    message: '打牌记账系统运行正常', 
    timestamp: new Date().toISOString(),
    version: '1.0.0'
  });
});

const PORT = process.env.PORT || 3000;

app.listen(PORT, () => {
  console.log(`🚀 打牌记账系统服务器运行在端口 ${PORT}`);
  console.log(`📡 API地址: http://localhost:${PORT}/api`);
  console.log(`🔌 WebSocket地址: ws://localhost:${PORT}`);
  console.log(`✅ 测试地址: http://localhost:${PORT}/test`);
}); 